<!doctype html>
<html>
    <head>
        <title>AudioTrack properties read from input stream metadata</title>
        <script src="../../resources/testharness.js"></script>
        <script src="../../resources/testharnessreport.js"></script>
            </head>
    <body>
        <script>
            async_test(function(t)
            {
                var audio = document.createElement("audio");
                audio.src = "../content/test.webm";

                audio.onloadedmetadata = t.step_func_done(function()
                {
                    assert_equals(audio.audioTracks.length, 1, "audioTracks.length");
                    assert_true(audio.audioTracks[0].enabled, "audioTrack.enabled");
                    assert_equals(audio.audioTracks[0].id, "2", "audioTrack.id");
                    assert_equals(audio.audioTracks[0].kind, "main", "audioTrack.kind");
                    assert_equals(audio.audioTracks[0].label, "", "audioTrack.label");
                    assert_equals(audio.audioTracks[0].language, "", "audioTrack.language");
                });
            });
            async_test(function(t)
            {
                var ac1 = new AudioContext();
                var stream1 = ac1.createMediaStreamDestination().stream;

                var ac2 = new AudioContext();
                var stream2 = ac2.createMediaStreamDestination().stream;

                var audio = document.createElement("audio");
                var tracks = [...stream1.getTracks(), ...stream2.getTracks()];
                var stream = new MediaStream(tracks);
                audio.srcObject = stream;
                audio.onloadedmetadata = t.step_func_done(function()
                {
                    assert_equals(audio.audioTracks.length, 2, "audioTracks.length");

                    assert_true(audio.audioTracks[0].enabled, "audioTrack.enabled");
                    assert_true("id" in audio.audioTracks[0], "audioTrack.id");
                    assert_equals(audio.audioTracks[0].kind, "main", "audioTrack.kind");
                    assert_true("label" in audio.audioTracks[0], "audioTrack.label");
                    assert_equals(audio.audioTracks[0].language, "", "audioTrack.language");

                    assert_false(audio.audioTracks[1].enabled, "audioTrack.enabled");
                    assert_true("id" in audio.audioTracks[1], "audioTrack.id");
                    assert_equals(audio.audioTracks[1].kind, "main", "audioTrack.kind");
                    assert_true("label" in audio.audioTracks[1], "audioTrack.label");
                    assert_equals(audio.audioTracks[1].language, "", "audioTrack.language");
                });
            });
        </script>
    </body>
</html>
